#pragma once
#include "afxwin.h"
#include "PairTrade.h"

// PairCalculatorDetail dialog

class PairCalculatorDetail : public CDialog, public L_Observer
{
	DECLARE_DYNAMIC(PairCalculatorDetail)

public:
	PairCalculatorDetail(PairTrade *tradePair, CWnd* pParent = NULL);   // standard constructor
	virtual ~PairCalculatorDetail();
	virtual BOOL Create(CWnd *pParentWnd = CWnd::FromHandle(L_GetMainWnd()));
	virtual BOOL OnInitDialog();
// Dialog Data
	enum { IDD = IDD_PAIRCALC_DETAIL };

protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

	DECLARE_MESSAGE_MAP()
	// L_Observer
	virtual void HandleMessage(L_Message const *pMsg);
public:
	afx_msg void OnClose();


private:
	void UpdateMarketComboBox();
	//data
	L_FullQuote *fullQuote1;
	L_FullQuote *fullQuote2;
	void SetSymbol1(const char *symbol);
	void SetSymbol2(const char *symbol);
	CString ValidatePairTrade();
	void SetStockValues(PairTrade *tradePair);
	
	void SetBuyStockAsSymbol1(PairTrade *tradePair);
	void SetSellStockAsSymbol1(PairTrade *tradePair);
	void SetBuyStockAsSymbol2(PairTrade *tradePair);
	void SetSellStockAsSymbol2(PairTrade *tradePair);
	PairTrade *m_tradePair_Old;
	PairTrade *m_tradePair_New;
	bool IsNewTrade;
	void GetLivePrice();
	bool isFormClosing;
	void UpdateControls();
	void UpdateDynamicValues();
	bool CanCalculate();
	void FillAll();
	
private:
	CEdit m_editSymbol1;
	CEdit m_editSymbol2;
private:
	CComboBox symbol1PriceOn;
	CComboBox symbol2PriceOn;
	CComboBox ctrl_cmbSymbol1PriceOn;
public:
	afx_msg void OnBnClickedSellradio2();
	afx_msg void OnBnClickedOk();
	CEdit ctrl_txtRatio;
	
	CComboBox ctrl_cmbSymbol2PriceOn;
	CStatic m_lblSharesForSymbol1;
	CStatic m_lblSharesForSymbol2;
	CComboBox m_DestinationComboSymbol1;
	CComboBox m_DestinationComboSymbol2;

	CButton BtnOK;
	int m_CompareSymbol;
	int m_orderTradeType;
	
	CEdit m_txtSharesForSymbol1;
	CEdit m_txtSharesForSymbol2;
	CEdit m_Symbol1Cash;
	CEdit m_Symbol2Cash;
	CEdit m_txtRequiredSpread;
	CComboBox m_cboOrderPriceOnSymbol1;
	CComboBox m_cboOrderPriceOnSymbol2;
	afx_msg void OnLostFocusSymbol1();
	afx_msg void OnLostFocusSymbol2();

	CStatic m_lblActualSpread;
	CStatic m_lblActualSpred;
	CStatic m_lblEvalution;
	afx_msg void OnTxtRatioChanged();
	afx_msg void OnTxtQtyChangeSymbol1();
	PairTrade* GetTradePair();
	afx_msg void OnOrderPriceOnChangedSymbol1();
	afx_msg void OnOrderPriceOnChangedSymbol2();
	afx_msg void OnPriceOnChangedSymbol1();
	afx_msg void OnPriceOnChangedSymbol2();
	afx_msg void OnCompareGTClicked();
	afx_msg void OnCompareGTEClicked();
	afx_msg void OnCompareLTClicked();
	afx_msg void OnCompareLTEClicked();
	afx_msg void OnTradeTypeBuyClicked();
	afx_msg void OnTradeTypeSellClicked();
	CStatic m_TradeSumarry;
	afx_msg void OnTxtRequiredSpreadChanged();
	afx_msg void OnBnClickedCancel();
	afx_msg void OnMarketChangedSymbol1();
	afx_msg void OnMarketChangedSymbol2();
};











